package o;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import o.avx.a;

public class eum implements ServiceConnection {
    private static final Object ˎ = new Object();
    private static List<LinkedHashMap<String, String>> ˏ = new ArrayList();
    private String ˊ;
    private avx ˋ = null;
    private String ॱ;

    public eum(String str, String str2) {
        this.ˊ = str;
        this.ॱ = str2;
    }

    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        synchronized (ˎ) {
            this.ˋ = a.ˎ(iBinder);
        }
        try {
            Logger.ˎ("AppReferrerServiceConnection", "set channel info to pps when service connect");
            this.ˋ.ˋ(this.ˊ, this.ॱ, 0);
        } catch (RemoteException e) {
            Logger.e("AppReferrerServiceConnection", "catch a RemoteException");
        } catch (Exception e2) {
            Logger.e("AppReferrerServiceConnection", "catch a Exception");
        }
        for (int i = 0; i < ˏ.size(); i++) {
            for (Entry entry : ((LinkedHashMap) ˏ.get(i)).entrySet()) {
                try {
                    Logger.ˎ("AppReferrerServiceConnection", "set channel cache info to pps");
                    this.ˋ.ˋ((String) entry.getKey(), (String) entry.getValue(), 0);
                } catch (RemoteException e3) {
                    Logger.e("AppReferrerServiceConnection", "catch a exception");
                }
            }
        }
        ˏ.clear();
        eba.ˋ().ˊ();
    }

    public void onServiceDisconnected(ComponentName componentName) {
        synchronized (ˎ) {
            this.ˋ = null;
        }
        this.ˊ = null;
        this.ॱ = null;
    }

    public void ˋ(String str, String str2) {
        synchronized (ˎ) {
            if (this.ˋ != null) {
                try {
                    Logger.ˎ("AppReferrerServiceConnection", "set channel info to pps directly");
                    this.ˋ.ˋ(str, str2, 0);
                } catch (RemoteException e) {
                    Logger.e("AppReferrerServiceConnection", "catch a exception");
                }
            } else {
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                linkedHashMap.put(str, str2);
                ˏ.add(linkedHashMap);
            }
        }
        eba.ˋ().ˊ.decrementAndGet();
        eba.ˋ().ˊ();
    }
}
